package br.com.infocruz.seam.crm.ejb.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.validator.Length;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.security.management.RoleName;

@Name("role")
@Entity
@Table(name = "TB_ROLE")
public class Role extends AbstractEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5184195989191905059L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID", precision = 22, scale = 0)
	private Long id;

	@Version
	@Column(name = "VERSION")
	private Integer version;

	@RoleName
	@Column(name = "NAME", length = 50)
	@Length(max = 50)
	private String name;

	@Column(name = "DESCRIPTION", length = 100)
	@Length(max = 100)
	private String description;

	public Role() {
	}
	
	public Role(Long id, Integer version, String name, String description) {
		super();
		this.id = id;
		this.version = version;
		this.name = name;
		this.description = description;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getVersion() {
		return version;
	}

	@SuppressWarnings("unused")
	private void setVersion(Integer version) {
		this.version = version;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Role other = (Role) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	

}
